package com.cat.controller;

import com.cat.pojo.Orders;
import com.cat.util.LayUI;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class ordersController {
    @Resource
    private com.cat.service.orderService orderService;

    @PostMapping("/saveOrders")
    @ResponseBody
    public boolean saveOrders(@RequestBody Orders orders) {
        System.out.println("111111111111");
        System.out.println(orders);
        System.out.println("222222222222");
//        LayUI lu =new LayUI();
//        lu.setCode(0);
//        lu.setMsg("");
//        lu.setData(orderService.saveOrders(orders));

        return orderService.saveOrders(orders);
    }
    @GetMapping("/delete/{id}")
    @ResponseBody
    public boolean delete( @PathVariable("id") int oid){
        System.out.println(oid);

        return orderService.delete(oid);
    }
    @GetMapping("/getOrdersByCid/{id}")
    @ResponseBody
    public LayUI getOrdersByCid(@PathVariable("id") int id){
        LayUI lu=new LayUI();
        lu.setCode(0);
        lu.setMsg("");
        lu.setData(orderService.getOrdersByCid(id));
        lu.setCount(5);
        return  lu;
    }


}
